home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / INTERNET / PPPop 1.6.sit / PPPop 1.6ƒ / Script Samples / Mail_Check Script < prev    next >
Text File  |  1997-07-26  |  3KB  |  121 lines

  1. --    Mail Check Version 
  2. --    Requires:
  3. --        Eudora 1.5.1 or later (Copyright QUALCOMM Incorporated)
  4. --        PPPop 1.4.1 or later
  5. --
  6. --    Based upon "Check The Mail" Copyright ゥ 1994  Mark Alldritt
  7. --
  8. --    Modified by Rob Friefeld <mailto:friefeld@deltanet.com> 8/3/96
  9.  
  10. --    The PPP driver should be set to quiet mode for unattended operation.
  11. --    Recommended to use Okey-Dokey or another utility to answer dialogs automatically
  12.  
  13. set Setting to true -- Set to False if you are not going to launch Eudora from a setting file
  14.  
  15. if Setting then set SettingFile to "Capella:Internet:deltanet:Delta Mail:Eudora Settings" as alias
  16. --    This has to be an !!ABSOLUTE PATH!! to your setting file. This example uses my path, not yours.
  17.  
  18. try
  19.     --    Get Eudora started so it is ready to receive script commands
  20.     if Setting then
  21.         tell application "Finder"
  22.             open SettingFile
  23.         end tell
  24.     else
  25.         tell application "Eudora Pro 3.1.1" to run
  26.     end if
  27.     
  28.     tell application "PPPop 1.6b4 PPC"
  29.         run
  30.         activate
  31.         set PPPWasUp to false
  32.         if (PPP up) then
  33.             set PPPWasUp to true
  34.         end if
  35.         if not (PPPWasUp) then
  36.             --    set some PPPop options for unattended operation, if you wish
  37.             copy launcher switch to holdlauncher
  38.             copy sound to holdsound
  39.             copy server to holdserver
  40.             set launcher switch to false
  41.             set sound to off
  42.             set server to "Delta 1" -- this is one of my servers
  43.             
  44.             connect
  45.             --    waste some time while the connection is established.  This is needed because MacPPP
  46.             --    operates asynchronously.
  47.             set i to 1
  48.             repeat while (i < 1000 and not (PPP up)) -- may need to increase on fast Macs
  49.                 set i to i + 1
  50.             end repeat
  51.             if not (PPP up) then
  52.                 error "PPP link not opened"
  53.             end if
  54.         end if
  55.     end tell
  56.     
  57.     
  58.     --    with timeout of 9999 seconds
  59.     tell application "Eudora Pro 3.1.1"
  60.         activate
  61.         connect with sending and checking
  62.     end tell
  63.     --    end timeout
  64.     
  65.     
  66.     --    Got the mail.    
  67.     --    If the PPP connection was up already, assume the user is present
  68.     --    at the computer to deal with the dialog.  Since the default choice is "don't Close"
  69.     --    the script will be well-behaved if an extension like Okey-Dokey is running.
  70.     
  71.     if PPPWasUp then
  72.         display dialog ツ
  73.             "Do you want to close the PPP link?" & return & ツ
  74.             "" buttons {"Close", "Don't Close"} default button "Don't Close" with icon caution
  75.         if button returned of the result = "close" then
  76.             tell application "PPPop 1.6b4 PPC"
  77.                 activate
  78.                 disconnect
  79.             end tell
  80.         end if
  81.     else
  82.         tell application "PPPop 1.6b4 PPC"
  83.             activate
  84.             disconnect
  85.             set launcher switch to holdlauncher
  86.             set sound to holdsound
  87.             set server to holdserver
  88.         end tell
  89.     end if
  90.     
  91.     
  92.     --    Finish with Eudora in front
  93.     tell application "Eudora Pro 3.1.1"
  94.         activate
  95.     end tell
  96.     
  97. on error errorString
  98.     --    Something went wrong.  Let the user know, and offer to close the connection
  99.     --    Default is close, since if an error is encountered, we want Okey-Dokey
  100.     --    to make the right choice.
  101.     
  102.     tell application "PPPop 1.6b4 PPC"
  103.         activate
  104.         if (PPP up) then
  105.             if not (PPPWasUp) then
  106.                 disconnect
  107.                 set launcher switch to holdlauncher
  108.                 set sound to holdsound
  109.                 set server to holdserver
  110.             end if
  111.         else
  112.             display dialog "Can't check the mail " & return & "(" & errorString & ")." & return & ツ
  113.                 "Close PPP link?" & return & ツ
  114.                 "" buttons {"Close", "Don't Close"} default button "Close" with icon caution
  115.             if button returned of the result = "Close" then
  116.                 disconnect
  117.             end if
  118.         end if
  119.     end tell
  120.     
  121. end try